package com.wsoft.oss.service;

import com.wsoft.oss.entity.OssFileEntity;
import com.wsoft.oss.query.MergePartQuery;
import com.wsoft.oss.query.PartUploadQuery;
import com.wsoft.oss.query.SecondUploadQuery;
import com.wsoft.oss.vo.FileUploadVO;
import org.springframework.core.io.InputStreamResource;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 功能描述
 *
 * @author: juiet
 * @date: 2024年09月24日 10:44
 */
public interface IOssService {
    /**
     * 附件上传
     *
     * @param multipartFileList
     * @param bucketType
     * @return
     * @throws Exception
     */
    List<FileUploadVO> uploadList(MultipartFile[] multipartFileList, Integer bucketType) throws Exception;

    /**
     * 获取文件 二进制流
     * @param ossFile
     * @param picType
     * @return
     * @throws IOException
     */
    InputStreamResource getInputStream(OssFileEntity ossFile, Integer picType) throws IOException;

    /**
     * 上传分片
     *
     * @param uploadQuery
     * @throws IOException
     * @throws Exception
     */
    void uploadPart(PartUploadQuery uploadQuery) throws IOException, Exception;

    /**
     * 秒传
     *
     * @param query
     * @return
     * @throws Exception
     */
    FileUploadVO secondUpload(SecondUploadQuery query) throws Exception;

    /**
     * 分片合并
     *
     * @param uploadQuery
     * @return
     * @throws Exception
     */
    FileUploadVO mergePart(MergePartQuery uploadQuery) throws Exception;


    /**
     * 分片下载
     * @param ossFile
     * @param picType
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    byte[] downloadPart(OssFileEntity ossFile, Integer picType, String request, HttpServletResponse response) throws Exception;

    /**
     * 删除文件
     * @param fileId
     * @return
     * @throws Exception
     */
    boolean deleteFile(Long fileId) throws Exception;
}
